package com.snake.springboot.custom.service.assemble.aicost;


import com.snake.springboot.custom.api.model.aicost.GeneratePayModel;
import com.snake.springboot.custom.api.model.points.PointsChangeModel;
import com.snake.springboot.custom.dao.mybatis.entity.aicost.FormulaDO;
import com.snake.springboot.custom.dao.mybatis.entity.aicost.GenerateFlowDO;
import org.snake.common.code.SerialNumberGeneratorFactory;
import org.snake.common.security.account.AccountData;
import org.snake.common.security.account.LoginAccount;

/**
 * <p>生成支付业务类
 * 类{@code GeneratePayAssembler} </br>
 * 创建时间2025/3/21 14:46
 * @author yangxt
 * @see
 */
public class GeneratePayAssembler {
    public static PointsChangeModel toPointsChangeModel(GeneratePayModel model, FormulaDO formulaDO) {
        PointsChangeModel pointsChangeModel = new PointsChangeModel();
        pointsChangeModel.setChangeType(6);
        pointsChangeModel.setRemark(formulaDO.getName());
        pointsChangeModel.setParentId(model.getChatId());
        pointsChangeModel.setCustomId(model.getCustomId());
        pointsChangeModel.setChangePoints(formulaDO.getPoints());
        return pointsChangeModel;
    }

    public static GenerateFlowDO toFlowDO(GeneratePayModel model, FormulaDO formulaDO) {
        GenerateFlowDO flowModel = new GenerateFlowDO();
        flowModel.setChatId(model.getChatId());
        flowModel.setFlowId(SerialNumberGeneratorFactory.buildId4Bean());
        flowModel.setFormulaCode(formulaDO.getFormulaCode());
        flowModel.setCustomId(model.getCustomId());
        flowModel.setRemark(formulaDO.getName());
        flowModel.setPoints(formulaDO.getPoints());

        AccountData account = LoginAccount.getAccount();
        flowModel.setOperator(account.getAccount());
        flowModel.setOperatorId(flowModel.getOperatorId());

        return flowModel;
    }
}
